package com.xr.miniprogram.domain.vo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.xr.miniprogram.domain.MiniProgramComment;
import com.xr.miniprogram.tools.StrListTool;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
 * 评论VO，处理评论图片
 */
@Data
public class MiniProgramCommentVO {
    /**
     * 评论id
     */
    private Long miniProgramCommentId;

    /**
     * 订单id
     */
    private Long orderId;

    /**
     * 用户id
     */
    private Long miniProgramUserId;

    /**
     * 评论内容
     */
    private String content;

    /**
     * 评论星级
     */
    private Long rate;

    /**
     * 图片url
     */
    private List<String> commentImgUrl;

    /**
     * 服务id
     */
    private Long serviceId;

    /**
     * 规格id
     */
    private Long standardsId;

    /**
     * 评论日期
     */
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    private Date createTime;

    /**
     * 用户名
     */
    private String nickName;

    /**
     * 用户头像
     */
    private String avatarUrl;

    /**
     * 服务名
     */
    private String serviceName;

    public static MiniProgramCommentVO toMiniProgramCommentVO(MiniProgramComment item){
        MiniProgramCommentVO commentVO = new MiniProgramCommentVO();
        commentVO.setMiniProgramCommentId(item.getMiniProgramCommentId());
        commentVO.setOrderId(item.getOrderId());
        commentVO.setMiniProgramUserId(item.getMiniProgramUserId());
        commentVO.setContent(item.getContent());
        commentVO.setRate(item.getRate());
        commentVO.setCommentImgUrl(StrListTool.stringToList(item.getCommentImgUrl()));
        commentVO.setServiceId(item.getServiceId());
        commentVO.setStandardsId(item.getStandardsId());
        commentVO.setCreateTime(item.getCreateTime());
        commentVO.setNickName(item.getNickName());
        commentVO.setAvatarUrl(item.getAvatarUrl());
        commentVO.setServiceName(item.getServiceName());
        return commentVO;
    }
}
